// ==UserScript==
// @name         维保看板
// @namespace    none
// @version      0.8
// @description  CSS修改脚本
// @author       Rainbow
// @match        *://172.20.31.148:9080/wb/*
// @grant        GM_xmlhttpRequest
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    console.log('Rainbow script Of Weibao')
    let username = 'admin'
    let pwd = 'admin'
    let loginUrl = 'http://172.20.31.148:8081/wb/base/sys/login?name=' + username + '&password=' + pwd
    let targetUrl = 'http://172.20.31.148:9080/wb/#/gateway'
    let pathOfusernameInput = '#app > div > div > div.box > div.log_id > div > input'
    let pathOfpwdInput = '#app > div > div > div.box > div.log_pwd > div > input'
    let pathOfBtn = '#app > div > div > div.box > div.btn > button.el-button.log_btn_sure.el-button--success'
    //填写用户名
    // let usernameInput = document.querySelector(pathOfusernameInput)
    // usernameInput.value = username
    // //填写密码
    // let pwdInput = document.querySelector(pathOfpwdInput)
    // pwdInput.value = pwd
    //点击登陆
    //document.querySelector(pathOfBtn).click()
    simLogin()
    function simLogin()
    {
        GM_xmlhttpRequest({
            method: 'GET',
            url: loginUrl,
            headers: {
                     "Content-Type": "application/json"
                 },
            onload: function(response) {
                if(response.status == 200 )
                {
                    let resp = eval("("+response.responseText+")")
                    if(resp.code == 0)
                    {
                        sessionStorage.setItem('token',resp.data.authToken)
                        window.location.href = targetUrl
                    }
                }
            },
        });
    }
})();